<template>
  <div class="app-container">
    <el-card class="box-card">

    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >

      <el-form-item label="证件编号" prop="certificateId">
        <el-input
          v-model="queryParams.certificateId"
          placeholder="请输入证件编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="姓名" prop="username" >
        <el-input
          v-model="queryParams.username"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="成员姓名" prop="familyName">
        <el-input
          v-model="queryParams.familyName"
          placeholder="请输入成员姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="成员身份证号" prop="familyIdNumber">-->
<!--        <el-input-->
<!--          v-model="queryParams.familyIdNumber"-->
<!--          placeholder="请输入成员身份证号"-->
<!--          clearable-->
<!--          maxlength="18"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

      <div style="text-align: right;margin-right:-9px;">
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </div>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:family:add']"
        >新增
        </el-button>
      </el-col>




      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:family:remove']"
        >删除
        </el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['system:family:import']"
        >导入
        </el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:family:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="familyList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="序号" align="center" :index="indexMethod" type="index" width="50"/>
      <el-table-column label="姓名" align="center" prop="username" v-if="columns[0].visible"/>
      <el-table-column label="证件编号" align="center" prop="certificateId" v-if="columns[1].visible"/>
      <el-table-column label="身份证号" align="center" prop="idNumber" v-if="columns[2].visible"/>
      <el-table-column label="部门" align="center" prop="deptid" v-if="columns[3].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_deptid" :value="scope.row.deptid"/>
        </template>
      </el-table-column>
      <el-table-column label="称谓" align="center" prop="title" v-if="columns[4].visible"/>
      <el-table-column label="成员姓名" align="center" prop="familyName" v-if="columns[5].visible"/>
      <el-table-column label="成员身份证号" align="center" prop="familyIdNumber" v-if="columns[6].visible"/>
      <el-table-column label="成员年龄" align="center" prop="familyAge" v-if="columns[7].visible"/>
      <el-table-column label="成员政治面貌" align="center" prop="familyPolitics" v-if="columns[8].visible"/>
      <el-table-column label="成员工作单位及职务" align="center" prop="familyOccupation" v-if="columns[9].visible"/>
      <el-table-column label="成员电话" align="center" prop="familyPhone" v-if="columns[10].visible"/>
      <el-table-column label="创建者" align="center" prop="createBy" v-if="columns[11].visible"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180" v-if="columns[12].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新者" align="center" prop="updateBy" v-if="columns[13].visible"/>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180" v-if="columns[14].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" v-if="columns[15].visible"/>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"

            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:family:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"

            @click="handleDelete(scope.row)"
            v-hasPermi="['system:family:remove']"
          >删除
          </el-button>

          <el-button
            size="mini"
            type="text"

            @click="handleView(scope.row)"
            v-hasPermi="['system:family:edit']"
          >详细
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>

    <!--导入 -->
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的亲属信息数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="danger" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改亲属信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">个人基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <!--第一行-->
            <el-row>
              <el-col :span="12">
                <el-form-item label="姓名" prop="username" label-width="24%">
<!--                  <el-input v-model="form.username" placeholder="请输入姓名"/>-->
                  <el-autocomplete
                    style="width: 100%"
                    placeholder="请输入姓名"
                    v-model="form.username"
                    :fetch-suggestions="querySearchAsync"
                    @select="handleSelect"
                  >
                  </el-autocomplete>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证件编号" prop="certificateId" label-width="24%">
                  <el-input v-model="form.certificateId" placeholder="请输入证件编号"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="身份证号" prop="idNumber" label-width="24%">
                  <el-input v-model="form.idNumber" maxlength="18" placeholder="请输入身份证号"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门" prop="deptid" label-width="24%">
<!--                  <el-input v-model="form.deptid" placeholder="请输入部门"/>-->
<!--                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择部门"/>-->
                  <el-select v-model="form.deptid" placeholder="请选择部门" style="width:90%;float:left">
                    <el-option
                      v-for="dict in dict.type.yh_deptid"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>


          <el-header>
            <el-divider content-position="left" label-width="24%">
              <p style="color: #00afff; font-size: 20px;">家庭成员信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="称谓" prop="title" label-width="24%">
                  <el-input v-model="form.title" placeholder="请输入称谓"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员姓名" prop="familyName" label-width="24%">
                  <el-input v-model="form.familyName" placeholder="请输入成员姓名"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="成员身份证号" prop="familyIdNumber" label-width="24%">
                  <el-input v-model="form.familyIdNumber" maxlength="18" placeholder="请输入成员身份证号"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员年龄" prop="familyAge" label-width="24%">
                  <el-input v-model="form.familyAge" placeholder="请输入成员年龄"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="成员政治面貌" prop="familyPolitics" label-width="24%">
<!--                  <el-input v-model="form.familyPolitics" placeholder="请输入成员政治面貌"/>-->
                  <el-select v-model="form.familyPolitics" placeholder="请输入成员政治面貌" style="width:100%" clearable>
                    <el-option
                      v-for="dict in dict.type.yh_politics"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员电话" prop="familyPhone" label-width="24%">
                  <el-input v-model="form.familyPhone" placeholder="请输入成员电话"/>
                </el-form-item>
              </el-col>

            </el-row>

            <el-row>
              <el-col :span="24">
                <el-form-item label="成员工作单位及职务" prop="familyOccupation" label-width="12%">
                  <el-input v-model="form.familyOccupation" placeholder="请输入成员工作单位及职务"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="remark" label-width="12%">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!--=======================================================================================-->

    <!-- 添加或修改承制单位信息对话框 -->
    <el-dialog :title="view.title" :visible.sync="view.open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">个人基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <!--第一行-->
            <el-row>
              <el-col :span="12">
                <el-form-item label="姓名" prop="username" label-width="24%">
                  <el-input v-model="form.username" placeholder="请输入姓名" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证件编号" prop="certificateId" label-width="24%">
                  <el-input v-model="form.certificateId" placeholder="请输入证件编号" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="身份证号" prop="idNumber" label-width="24%">
                  <el-input v-model="form.idNumber" maxlength="18" placeholder="请输入身份证号" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门" prop="deptid" label-width="24%">
                  <!--                  <el-input v-model="form.deptid" placeholder="请输入部门"/>-->
<!--                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择部门" disabled="true"/>-->
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>


          <el-header>
            <el-divider content-position="left" label-width="24%">
              <p style="color: #00afff; font-size: 20px;">家庭成员信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="称谓" prop="title" label-width="24%">
                  <el-input v-model="form.title" placeholder="请输入称谓" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员姓名" prop="familyName" label-width="24%">
                  <el-input v-model="form.familyName" placeholder="请输入成员姓名" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="成员身份证号" prop="familyIdNumber" label-width="24%">
                  <el-input v-model="form.familyIdNumber" placeholder="请输入成员身份证号" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员年龄" prop="familyAge" label-width="24%">
                  <el-input v-model="form.familyAge" placeholder="请输入成员年龄" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row>
              <el-col :span="12">
                <el-form-item label="成员政治面貌" prop="familyPolitics" label-width="24%">
                  <el-input v-model="form.familyPolitics" placeholder="请输入成员政治面貌" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="成员电话" prop="familyPhone" label-width="24%">
                  <el-input v-model="form.familyPhone" placeholder="请输入成员电话" readonly="true"/>
                </el-form-item>
              </el-col>

            </el-row>

            <el-row>
              <el-col :span="24">
                <el-form-item label="成员工作单位及职务" prop="familyOccupation" label-width="12%">
                  <el-input v-model="form.familyOccupation" placeholder="请输入成员工作单位及职务" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="remark" label-width="12%">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="viewCancel">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>


<style>
  .el-header, .el-footer {
    background-color: #FFFFFF;
    color: #333;
    text-align: left;
    line-height: 60px;
    font-style: oblique;

  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    background-color: #FFFFFF;
    color: #333;
    text-align: center;
    line-height: 160px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  .el-dialog__title {
    /*color: #1ab394;*/
    font-weight: bold;
    font-size: 25px;
  }

  .input_text {
    background-color: #efefef;
    border-color: #efefef;
    border-style: solid;
    border-top-width: 0px;
    border-right-width: 0px;
    border-bottom-width: 1px;
    border-left-width: 0px;

  }
</style>
<script>
  import {getToken} from "@/utils/auth";
  import {listFamily, getFamily, delFamily, addFamily, updateFamily} from "@/api/module/ls/family";
  import {treeselect} from "@/api/system/dept";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import {listBaseinfo} from "@/api/module/ls/baseinfo";
  export default {
    name: "Family",
    components: { Treeselect },
    dicts: ['yh_politics','yh_deptid'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        //部门树选择
        deptOptions: undefined,
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 基础信息表格数据
        baseInfoList: [],
        // 亲属信息表格数据
        familyList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          username: null,
          certificateId: null,
          idNumber: null,
          deptid: null,
          title: null,
          familyName: null,
          familyIdNumber: null,
          familyAge: null,
          familyPolitics: null,
          familyOccupation: null,
          familyPhone: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        },
        // 用户查询参数
        view: {
          // 是否显示弹出层（用户查询）
          open: false,
          // 弹出层标题（用户查询）
          title: "",
        },
        // 列信息
        columns: [
          {key: 0, label: `姓名`, visible: true},
          {key: 1, label: `证件编号`, visible: true},
          {key: 2, label: `身份证号`, visible: false},
          {key: 3, label: `部门`, visible: false},
          {key: 4, label: `称谓`, visible: true},
          {key: 5, label: `成员姓名`, visible: true},
          {key: 6, label: `成员身份证号`, visible: true},
          {key: 7, label: `成员年龄`, visible: false},
          {key: 8, label: `成员政治面貌`, visible: false},
          {key: 9, label: `成员工作单位及职务`, visible: false},
          {key: 10, label: `成员电话`, visible: false},
          {key: 11, label: `创建者`, visible: false},
          {key: 12, label: `创建时间`, visible: false},
          {key: 13, label: `更新者`, visible: false},
          {key: 14, label: `更新时间`, visible: false},
          {key: 15, label: `备注`, visible: false}
        ],
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          certificateId: [
            { required: true, message: "证件编号不能为空", trigger: "blur" },
          ],
          idNumber: [
            { required: true, message: "身份证号不能为空", trigger: "blur" },
          ],
          deptid: [
            { required: true, message: "部门不能为空", trigger: "blur" },
          ],
          username: [
            { required: true, message: "姓名不能为空", trigger: "blur" },
          ],
        },
        // 用户导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: {Authorization: "Bearer " + getToken()},
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/ls/family/importData"
        }
      };
    },
    created() {
      this.getList();
      this.getTreeselect();
      this.getBaseInfo();
    },
    methods: {
      getBaseInfo() {
        listBaseinfo().then(response => {
          this.baseInfoList = response.rows;
          console.log('baseInfoList '+this.baseInfoList)
        });
      },
      //queryString 为在框中输入的值
      //cb 回调函数，将处理好的数据推回
      querySearchAsync(queryString, cb) {
        //因为autocomplete只识别value字段,所以用replace(/需要用的字段/g,"value")，将需要用的字段全部替换成value
        //(/***/g 是全部替换，如果不用全部替换，可以参考https://www.w3school.com.cn/jsref/jsref_replace.asp)
        let baseInfoJson= JSON.parse(JSON.stringify(this.baseInfoList).replace(/username/g,"value"));
        console.log('baseInfoJson '+baseInfoJson)
        let results = queryString ? baseInfoJson.filter(this.createStateFilter(queryString)) : baseInfoJson;
        console.log('results '+results)
        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
          cb(results);
        }, 0.5*1000);
      },
      //根据输入的字段进行筛选
      createStateFilter(queryString) {
        return (state) => {
          return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },

      //将其他数据自动补全，采用覆盖的方法
      handleSelect(item){
        this.form.username = item.value;
        this.form.idNumber=item.idNumber;
        this.form.certificateId=item.certificateId;
        this.form.deptId = item.deptId;
      },

      getTreeselect(){
        treeselect().then(response => {
          this.deptOptions = response.data;
        });
      },
      /** 查询亲属信息列表 */
      getList() {
        this.loading = true;
        listFamily(this.queryParams).then(response => {
          this.familyList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 取消按钮
      viewCancel() {
        this.view.open = false;
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          username: null,
          certificateId: null,
          idNumber: null,
          deptid: null,
          title: null,
          familyName: null,
          familyIdNumber: null,
          familyAge: null,
          familyPolitics: null,
          familyOccupation: null,
          familyPhone: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        };
        this.resetForm("form");
      },
      /** 下载模板操作 */
      importTemplate() {
        this.download('/ls/family/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`)
      },
      /** 导入按钮操作 */
      handleImport() {
        this.upload.title = "用户导入";
        this.upload.open = true;
      },
      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true;
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.upload.open = false;
        this.upload.isUploading = false;
        this.$refs.upload.clearFiles();
        this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
        this.getList();
      },
      // 提交上传文件
      submitFileForm() {
        this.$refs.upload.submit();
      },
      indexMethod(index) {
        index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
        return index
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加亲属信息";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getFamily(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改亲属信息";
        });
      },
      /** 详细按钮操作 */
      handleView(row) {
        // const id = row.id || this.ids
        // getFamily(id).then(response => {
        //   this.form = response.data;
        //   this.view.open = true;
        //   this.view.title = "亲属信息查看";
        // });
        const id = row.id;
        this.$router.push({ path:"/jiben/family_detail", query: {id}});
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateFamily(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addFamily(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        const i=row.familyName || this.is;
        this.$modal.confirm('是否确认删除亲属姓名为"' + i + '"的数据项？').then(function () {
          return delFamily(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('system/family/export', {
          ...this.queryParams
        }, `family_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>
